<?php

namespace app\admin\model\choi;

use think\Model;
use think\Session;


class UserMoneyLog extends Model
{

    

    

    // 表名
    protected $table = 'user_money_log';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];


    /**
     * 新增余额变化
     */
    public static function add($user, $money, $memo = '')
    {
        return self::create([
            'user_id' => $user->user_id,
            'money' => $money,
            'before' => $user->money,
            'after' => $user->money + $money,
            'memo' => $memo,
            'createtime' => time()
        ]);
    }





}
